<HTML> 
<HEAD> 
	<TITLE>3rd Party ROBOTC Drivers</TITLE> 
<link href="tabs.css" rel="stylesheet" type="text/css"/> 
<link href="doxygen.css" rel="stylesheet" type="text/css"/> 
</HEAD> 
 
<BODY bgcolor="#ffffff" link="#000000" vlink="#000000"> 
<table width="100%" bgcolor="navy" cellspacing=0 cellpadding=1 border=0> 
<tr><td><table width="100%" bgcolor="#EEEEDD" cellspacing=0 cellpadding=3 border=0> 
<tr> 
    <td width="33%" align="left"> <img src="images/LOGO_NXT.gif" width=266 height=44 border="0" alt="Mindstorms"></td> 
    <td><b><font size="+3" color="navy">3rd Party ROBOTC Drivers</font></b></td> 
    <td align="right"> <img src="images/logo.png" width=44 height=44 border="0" alt="RobotC"></td>     
</tr> 
  <tr bgcolor="#cccc99" align="right"> 
          <td colspan=3> <font face="arial" size="-1"> [<a href=main.html>Home</a>] [<a target=_top href="https://sourceforge.net/projects/rdpartyrobotcdr/">Download</a>] [<a target=_top href="http://apps.sourceforge.net/mantisbt/rdpartyrobotcdr/my_view_page.php">Submit a bug/suggestion</a>]  [<a target=_top href="http://www.robotc.net/forums/">ROBOTC Forums</a>] [<a target=_top href="http://botbench.com">Blog</a>] [<a target=_top href="http://sourceforge.net/donate/index.php?group_id=257238">Support this project</a>]</font> </td> 
</tr> 
</table></td></tr> 
</table> 
<!-- Generated by Doxygen 1.7.2 -->
<div class="header">
  <div class="headertitle">
<h1>hitechnic-superpro-exp6b.c</h1>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="preprocessor">#pragma config(Sensor, S1,     HTSPB,                sensorI2CCustom9V)</span>
<span class="preprocessor"></span><span class="comment">//*!!Code automatically generated by &#39;ROBOTC&#39; configuration wizard               !!*//</span>

<span class="comment">/*   HiTechnic Experimenter&#39;s Kit for the SuperPro</span>
<span class="comment"></span>
<span class="comment">Experiment - 6 Variation - Complex Reaction Time Measurement</span>
<span class="comment"></span>
<span class="comment">This program measures the time taken to press a button switch after an LED is turned on.</span>
<span class="comment"></span>
<span class="comment">*/</span>

<span class="preprocessor">#include &quot;<a class="code" href="hitechnic-superpro_8h.html" title="HiTechnic SuperPro Prototype Board driver.">drivers/hitechnic-superpro.h</a>&quot;</span>

task main() {
  ubyte buttonmask = 0;

  <span class="comment">// The data to be written: 0x30 = 110000 binary,</span>
  <span class="comment">// makes B4,B5 digital ports outputs.</span>
  <a name="a0"></a><a class="code" href="group___h_t_s_p_b.html#ga9efaffb1a442aa3d1765b623536141a4">HTSPBsetupIO</a>(HTSPB, 0x03);

  <span class="keywordflow">while</span>(<span class="keyword">true</span>) {
    <span class="comment">// Turn off all outputs</span>
    <a name="a1"></a><a class="code" href="group___h_t_s_p_b.html#ga6d342ff5d1f49c472a445669a0363d96">HTSPBwriteIO</a>(HTSPB, 0x00);

    eraseDisplay();
    nxtDisplayTextLine(2, <span class="stringliteral">&quot;running&quot;</span>);

    wait1Msec(random(5000) + 3000);

    <span class="comment">// Turn on a random LED</span>
    <span class="keywordflow">if</span>(random(1) &gt; 0) {
      <a class="code" href="group___h_t_s_p_b.html#ga6d342ff5d1f49c472a445669a0363d96">HTSPBwriteIO</a>(HTSPB, 0x01);
      buttonmask = 0x10;
    } <span class="keywordflow">else</span> {
      <a class="code" href="group___h_t_s_p_b.html#ga6d342ff5d1f49c472a445669a0363d96">HTSPBwriteIO</a>(HTSPB, 0x02);
      buttonmask = 0x20;
    }

    time1[T1] = 0;

    <span class="keywordflow">while</span> (<a name="a2"></a><a class="code" href="group___h_t_s_p_b.html#ga5bf4cf880799f31f556b1f9c69cae5bb">HTSPBreadIO</a>(HTSPB, 0x30) != buttonmask) {
      wait1Msec(5);
    }

    eraseDisplay();
    nxtDisplayTextLine(2, <span class="stringliteral">&quot;Time: %d&quot;</span>, time1[T1]);

    <span class="keywordflow">while</span> (<a class="code" href="group___h_t_s_p_b.html#ga5bf4cf880799f31f556b1f9c69cae5bb">HTSPBreadIO</a>(HTSPB, 0x30) != 0x30) {
      wait1Msec(5);
    }
  }
}
</pre></div> </div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Wed Mar 13 2013 19:56:42 for ROBOTC Drivers by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
</body>
</html>
